<template>
  <div class="hom-pro-list warp">
    <div class="title">
      <div class="title-text">每日上新</div>
      <div
          v-show="componentContent.showMore"
          class="btn-more"
          @click="jumpLink(componentContent.linkObj)"
      >
        查看全部
      </div>
    </div>
    <swiper
        class="product-list"
        :disable-touch="productData.length < 4" :indicator-dots="false" :autoplay="true" :display-multiple-items="productData.length >= 4?4:productData.length"
    >
      <swiper-item v-for="(item,index) in productData" :key="item.id" class="product-item" @click="jumpProductDetail(item)">
        <div class="box">
          <div class="icon">{{index+1 < 10? `0${index+1}` : index+1}}</div>
          <div class="product-img">
            <img class="img" :src="item.image" alt="" />
          </div>
          <div class="product-info">
            <div class="product-name">{{ item.productName }}</div>
            <div class="product-price">￥{{ item.price }}</div>
          </div>
        </div>
      </swiper-item>
    </swiper>
  </div>
</template>

<script setup>
import { toRefs } from 'vue';
import commonMixin from '../mixin';
import { VUE_APP_STATIC_URL } from "@/config/api";

const props = defineProps({
  componentContent: {
    type: Object,
    default () {
      return {};
    },
  },
});
const { componentContent } = toRefs(props);
const { productData, jumpProductDetail, jumpLink } = commonMixin(componentContent);
</script>

<style lang="scss" scoped>
@import "../../../../../style/images";
.hom-pro-list {
  height: 352rpx;
  background: url("#{$base-path}ui-static/zwx-static/store/bg-new.png") no-repeat top center / 100% 100%;
  padding: 20rpx;
  box-sizing: border-box;
  margin: 0 30rpx;
  .title {
    display: flex;
    justify-content: space-between;
    padding-bottom: 17rpx;
    .title-text{
      padding: 11rpx 0 18rpx;
      position: relative;
      font-weight: bold;
      font-size: 36rpx;
      line-height: 1em;
      &:after {
        content: "";
        display: block;
        width: 67rpx;
        height: 5rpx;
        background: linear-gradient(90deg, #FF9000, #FF5000);
        border-radius: 3rpx;
        position: absolute;
        bottom: 0rpx;
        left: 50%;
        margin-left: -33.5rpx;
      }
    }
    .btn-more {
      width: 146rpx;
      height: 52rpx;
      border-radius: 26rpx;
      border: 1px solid #8B4B23;
      font-size: 28rpx;
      color: #8B4B23;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
    }
  }
  .product-list {
    margin-left: -10rpx;
    height: 250rpx;
    .product-item {
      .box{
        padding-left: 10rpx;
        width: 164rpx;
        position: relative;
      }
      .product-img {
        margin-bottom: 14rpx;
        .img {
          border-radius: 8rpx;
          width: 100%;
          height: 154rpx;
        }
      }
      .product-info {
        text-align: center;
        .product-name {
          font-size: 20rpx;
          color: #6c6c6c;
          line-height: 21rpx;
          margin-bottom: 9rpx;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .product-price {
          font-size: 26rpx;
          font-weight: bold;
          color: #ff5000;
          line-height: 1;
        }
      }
      .icon {
        content: "";
        display: block;
        width: 28rpx;
        height: 29rpx;
        background-repeat: no-repeat;
        background-size: 100% 100%;
        position: absolute;
        right: 10rpx;
        top: 0;
        color: #fff;
        text-align: center;
        font-size: 18rpx;
        background-image: url("#{$base-path}ui-static/zwx-static/home/tag04.png");
      }
      &:nth-child(1) {
        .icon{
          background-image: url("#{$base-path}ui-static/zwx-static/home/tag01.png");
        }
      }
      &:nth-child(2) {
        .icon{
          background-image: url("#{$base-path}ui-static/zwx-static/home/tag02.png");
        }
      }
      &:nth-child(3) {
        .icon{
          background-image: url("#{$base-path}ui-static/zwx-static/home/tag03.png");
        }
      }
    }
  }
}

.pagination {
  display: flex;
  justify-content: center;
  width: 100%;
  bottom: 0;
  :deep(.swiper-pagination-bullet) {
    width: 24rpx;
    height: 4rpx;
    background: #ffffff;
    opacity: 0.5;
    border-radius: 2rpx;
    margin: 0 10px;
  }
  :deep(.swiper-pagination-bullet-active) {
    opacity: 1;
  }
}
</style>
